/* eslint camelcase: off, guard-for-in: off, no-restricted-syntax: off, */
// import type { LocaleMessages, VueMessageType } from 'vue-i18n';

// const modules = import.meta.glob(['./modules/*.js', '!./modules/*.(ig|ignore)'], { eager: true });

// 初始化时只导入指定的翻译文件
const modules = import.meta.glob(['./modules/common.js', './modules/pageTitle.js'], {
    eager: true,
});

type LangFile = {
    lang_ar?: object;
    lang_en?: object;
    lang_in?: object;
    lang_tr?: object;
    lang_ur?: object;
    lang_zh?: object;
};

const localeEN: object = {};
const localeZH: object = {};
const localeAR: object = {};
const localeUR: object = {};
const localeTR: object = {};
const localeIN: object = {};

for (const path in modules) {
    const {
        lang_zh = {},
        lang_en = {},
        lang_ar = {},
        lang_ur = {},
        lang_tr = {},
        lang_in = {},
    } = <LangFile>modules[path];
    const moduleName: string = /\/([a-zA-Z0-9]*)\.js/.exec(path)?.[1] ?? '';
    // 线上环境不导入中文
    if (!import.meta.env.PROD) {
        localeZH[moduleName] = lang_zh;
    }
    localeEN[moduleName] = lang_en;
    localeAR[moduleName] = lang_ar;
    localeUR[moduleName] = lang_ur;
    localeTR[moduleName] = lang_tr;
    localeIN[moduleName] = lang_in;
}

export { localeEN, localeZH, localeAR, localeUR, localeTR, localeIN };
